package com.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.google.gson.Gson;
import com.google.gson.annotations.Expose;

@JsonIgnoreProperties(ignoreUnknown=true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RespBase {
	@Expose
	String code;
	@Expose
	String message;
	Object data;
	
	static public final String STATUS_SUCCESS = "0000";
	static public final String STATUS_ERR_FAIL = "0001";
	static public final String STATUS_ERR_PARAM_ILLEGAL = "0002";
	static public final String STATUS_ERR_CASH = "1000";
	static public final String STATUS_ERR_COOKIE_EMPTY= "0097";
	static public final String STATUS_ERR_ACCOUNT_NOT_EXIST = "0098";
	static public final String STATUS_ERR_TOKEN = "0099";
	static public final String STATUS_ERR_USERBILLSHAR_ENOBIND = "2000";
	static public final String STATUS_ERR_SYSTEM = "9999";//TODO 
	
	static public final String MESSAGE_SUCCESS = "成功";
	public String toJson()
	{
		return new Gson().toJson(this);
	}
	public RespBase()
	{
		code = STATUS_SUCCESS;
		message = MESSAGE_SUCCESS;
	}
	public RespBase(Object data)
	{
		code = STATUS_SUCCESS;
		message = MESSAGE_SUCCESS;
		this.data = data;
	}
	public RespBase(String message)
	{
		this.code = STATUS_ERR_FAIL;
		this.message = message;
	}
	
	public RespBase(String status,String message)
	{
		this.code = status;
		this.message = message;
	}
	
	public RespBase setStatusMessage(String status,String message)
	{
		this.code =status;
		this.message = message;
		return this;
	}
	
	public RespBase setStatusMessage(String message)
	{
		this.code = STATUS_ERR_FAIL;
		this.message = message;
		return this;
	}
	
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	
	
}
